package net.a6polo.a6poloweibo;

import android.os.Bundle;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.graphics.Color;
import android.view.Menu;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class MainTabActivity extends TabActivity {

	private static final String HOME_TAB="home"; 
	private static final String AT_TAB="at"; 
	private static final String MSG_TAB="msg"; 
	private static final String MORE_TAB="more"; 
	
	private TabHost tabHost;
	
	private RadioGroup radioGroup;
	private RadioButton homeButton;
	private RadioButton atButton;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_tab);
        
        tabHost = this.getTabHost();
        
        TabSpec homeSpec=tabHost.newTabSpec(HOME_TAB).setIndicator(HOME_TAB).setContent(new Intent(this,MainActivity.class));
        TabSpec atSpec=tabHost.newTabSpec(AT_TAB).setIndicator(AT_TAB).setContent(new Intent(this,AtActivity.class));
//        TabSpec msgSpec=tabHost.newTabSpec(MSG_TAB).setIndicator(MSG_TAB).setContent(new Intent(this,MsgActivity.class));
//        TabSpec moreSpec=tabHost.newTabSpec(MORE_TAB).setIndicator(MORE_TAB).setContent(new Intent(this,MoreActivity.class));
        
        tabHost.addTab(homeSpec);
        tabHost.addTab(atSpec);
//        tabHost.addTab(msgSpec);
//        tabHost.addTab(moreSpec);
        
        radioGroup = (RadioGroup)findViewById(R.id.rg_main_btns);
        homeButton = (RadioButton)findViewById(R.id.rd_home);
        atButton = (RadioButton)findViewById(R.id.rd_at);
        
        radioGroup =  (RadioGroup) this.findViewById(R.id.rg_main_btns);
        
        radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener()
    		{
    			
    			public void onCheckedChanged(RadioGroup group, int checkedId)
    			{
    				
    				switch (checkedId)
    				{
    				case R.id.rd_home:
    					tabHost.setCurrentTabByTag(HOME_TAB);
    					//homeButton.setBackgroundColor(getResources().getColor(R.color.white));
    					break;
    					
    				case R.id.rd_at:
    					tabHost.setCurrentTabByTag(AT_TAB);
    					//atButton.setBackgroundColor(getResources().getColor(R.color.white));
    					break;
    					
    				case R.id.rd_msg:
    					tabHost.setCurrentTabByTag(MSG_TAB);
    					break;
    					
    				case R.id.rd_more:
    					tabHost.setCurrentTabByTag(MORE_TAB);
    					break;

    				default:
    					break;
    				}
//    				
//    				RadioButton checkedButton = (RadioButton)findViewById(radioGroup.getCheckedRadioButtonId());
//    				checkedButton.setBackgroundColor(getResources().getColor(R.color.white));
    				
    			}
    			
    		});
    }


}
